package com.project.seckill.common.exception;

public class MyException extends RuntimeException {

    private static final long serialVersionUID = 1L;

    /**
     * 错误码
     */
    protected String errorCode;
    /**
     * 错误信息
     */
    protected String errorMsg;

    public MyException() {
        super();
    }

    public MyException(BaseException baseException) {
        super(baseException.getResultCode());
        this.errorCode = baseException.getResultCode();
        this.errorMsg = baseException.getResultMsg();
    }

    public MyException(BaseException baseException,Throwable cause){
        super(baseException.getResultCode(), cause);
        this.errorCode = baseException.getResultCode();
        this.errorMsg = baseException.getResultMsg();
    }

    public MyException(String errorMsg){
        super(errorMsg);
        this.errorCode = "500";
        this.errorMsg = errorMsg;
    }

    public MyException(String errorCode,String errorMsg){
        super(errorCode);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public String getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    @Override
    public Throwable fillInStackTrace(){
        return this;
    }
}
